package com.chefu.carowner.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.chefu.carowner.pojo.UserCars;
import com.chefu.carowner.service.UserCarsService;
import com.chefu.common.pojo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author goodgoodstudy
 * @since 2021-03-30
 */
@RestController
@RequestMapping("/carOwner")
public class UserCarsController {

    @Autowired
    UserCarsService userCarsService;

    /**
     * 查询车主车辆
     */
    @GetMapping("/cars/{uid}")
    public R findCars(@PathVariable("uid")Long uid){
        List<UserCars> userCarsList = userCarsService.list(new QueryWrapper<UserCars>().eq("user_id", uid));
        return R.ok().data("carList", userCarsList);
    }



}

